/**
 * @description 获取用户信息
 */

import $http from '@/utils/http'
import { globalConfig } from '@/config'
const hostUrl =
  window.__TAURI__ || window.electronAPI
    ? window.localStorage.getItem('host_id') || globalConfig.hostIp
    : globalConfig.agent

// 游客注册
export const ternimalRegister = (params) => {
  return $http.postForm({
    url: `${hostUrl}/api/terminal/login`,
    params
  })
}

// 用户注册
export const userRegister = (params) => {
  return $http.postForm({
    url: `${hostUrl}/api/account/reg`,
    params
  })
}

// 用户登录
export const userLogin = (params) => {
  return $http.postForm({
    url: `${hostUrl}/api/account/login`,
    params
  })
}

// 用户是否处于登录状态
export const userLoginStatus = (params) => {
  return $http.postForm({
    url: `${hostUrl}/api/account/online_status`,
    params
  })
}

// 用户退出
export const outLogin = (params) => {
  return $http.postForm({
    url: `${hostUrl}/api/account/log_out`,
    params
  })
}

// 判断用户token是否失效
export const userAlive = (params = {}) => {
  return $http.get({
    url: `${hostUrl}/api/account/is_alive`,
    params
  })
}

// 查询供应商
export const queryProviderList = (params) => {
  return $http.get({
    url: `${hostUrl}/api/content/list_content_provider`,
    params
  })
}

// 查询游戏列表
export const queryGameList = (params) => {
  return $http.get({
    url: `${hostUrl}/api/content/list_content`,
    params
  })
}

// 查询游戏分类
export const queryGameCategory = (params) => {
  return $http.get({
    url: `${hostUrl}/api/content/list_all_category`,
    params
  })
}

// 新增游戏记录
export const addLately = (params) => {
  return $http.postForm({
    url: `${hostUrl}/api/user/add_content_lately`,
    params
  })
}

// 删除游戏记录
export const delLately = (params) => {
  return $http.postForm({
    url: `${hostUrl}/api/user/del_content_lately`,
    params
  })
}

// 查询游戏记录
export const getLatelyList = (params) => {
  return $http.get({
    url: `${hostUrl}/api/user/list_content_lately`,
    params
  })
}

// 查询游戏调度
export const getDispatchList = (params) => {
  return $http.get({
    url: `${hostUrl}/api/dispatch/query_term_non_terminated_dispatch`,
    params
  })
}

// 查询游戏启动状态
export const getDispatchHistory = (params) => {
  return $http.get({
    url: `${hostUrl}/api/dispatch/query_dispatch_history`,
    params
  })
}

// 获取配置接口
export const getConfigList = (params) => {
  return $http.get({
    url: `${hostUrl}/api/config/get`,
    params
  })
}

// 查询最近调度信息
export const getLastDispatch = (params) => {
  return $http.get({
    url: `${hostUrl}/api/dispatch/query_dispatch`,
    params
  })
}

// 查询可用调度列表
export const queryTermDispatches = (params) => {
  return $http.get({
    url: `${hostUrl}/api/dispatch/query_term_dispatches`,
    params
  })
}

// 追加内容到调度
export const appendTermDispatch = (params) => {
  return $http.postForm({
    url: `${hostUrl}/api/dispatch/append_content`,
    params
  })
}

// 打开moonlight客户端

export const focusDispatch = (params) => {
  return $http.postForm({
    url: `${hostUrl}/api/dispatch/focus_top_up`,
    params
  })
}

// 查询帮助列表
export const getHelpList = (params) => {
  return $http.get({
    url: `${hostUrl}/api/help/list`,
    params
  })
}

// 提交意见反馈
export const addFeedBack = (params) => {
  return $http.postForm({
    url: `${hostUrl}/api/feedback/add`,
    params
  })
}

// 获取当前用户调度列表
export const getAllDispatch = (params) => {
  return $http.get({
    url: `${hostUrl}/api/control/dispatch_list`,
    params
  })
}
